package parts5.lesson60;

import java.util.Observable;
import java.util.Observer;

/**
 * 买房者，观察房子
 */
public class Person implements Observer {
    private String name;
    public Person(String name){
        this.name=name;
    }
    @Override
    public void update(Observable o, Object arg) {
        if(o instanceof House){
            //如果发现House的价格发生了变更
            if(arg instanceof Double){
                System.out.println(o+"，当前新价格："+arg);
            }

        }
    }

    @Override
    public String toString() {
        return this.name;
    }
}
